package com.rd.student.jiaji.class3.wangyanbo.task27;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class TestPrint {
    public static void main(String[] args) throws Exception{
        //开始定向输入
        FileInputStream fis = new FileInputStream("in.txt");
        System.setIn(fis);

        Scanner scanner= new Scanner(System.in);
        StringBuffer builder = new StringBuffer();
        while (scanner.hasNextLine()){
//            System.out.println(scanner.next());
            builder.append(scanner.nextLine()+"\n");
        }
        fis.close();

    }
    public static void testOut()throws Exception{
        //开始定向输出
        PrintStream ps = new PrintStream(new FileOutputStream("out.txt"));
        System.setOut(ps);
        System.out.println("hello out txt");
        ps.close();
    }
    public  static void test()throws Exception{
        FileOutputStream fos = new FileOutputStream("streamPrint.txt");
        PrintStream ps = new PrintStream(fos);
        ps.println("hello PrintStream");
        System.out.println("hello PrintStream");
        //在使用处理流时，只要关闭处理流就可，系统会自动关闭处理流包装的节点流
        ps.close();
    }

}
